<!DOCTYPE html>
<html lang="zh-CN">
{% load staticfiles %}
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="author" content="常伟">
  <title>知识问答</title>
  <link rel="stylesheet" href="{% static 'libs/bootstrap/css/bootstrap.css' %}">
  <link rel="stylesheet" href="{% static 'libs/font-awesome/css/font-awesome.css' %}">
  <link rel="stylesheet" href="{% static 'libs/simditor/styles/simditor.css' %}">
  <link rel="stylesheet" href="{% static 'css/main.css' %}">
</head>

<body>
  <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">智游问答</a>
      </div>
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
          <li><a href="/question/">最新问题 <span class="sr-only">(current)</span></a></li>
          <li><a href="#">最难问题</a></li>
          <li><a href="#">我的提问</a></li>
          <li><a href="/question/myanswer/">我的回答</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
          <li class="dropdown">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user }} <span class="caret"></span></a>
            <ul class="dropdown-menu">
              <li><a href="#">个人信息</a></li>
              <li><a href="/auth/logout/">退出登录</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </nav>
  <div class="container">
    <div class="row">
      <div class="col-md-3 col-md-push-9">
<div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">分类</h3>
          </div>
          <div class="panel-body keywords">
            {% for a in type %}
            <span class="label label-default">{{ a.types }}</span>
              {% endfor %}

          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">关键词</h3>
          </div>
          <div class="panel-body keywords">
            {% for a in tag %}
            <span class="label label-default">{{ a.tags }}</span>
              {% endfor %}

          </div>
        </div>
      </div>
      <div class="col-md-9 col-md-pull-3">
        <div class="panel panel-default">
          <div class="panel-body question">
          <div class="row">
            <div class="col-xs-12">
              <h2>回答问题</h2>
            </div>
          </div>

            <div class="media">
              <a class="media-left" href="#">
                <img class="media-object" src="">
              </a>
              <div class="media-body">
                <h4 class="media-heading">{{ a.question }}</h4>
              {% autoescape off %}
              {{ a.abstract }}
              {% endautoescape %}
                <div class="row keys">
                  <div class="col-md-8"><span class="label label-success">{{ a.type.types }}</span>
                    <span class="label label-success">{{ a.tag.tags }}</span></div>
                  <div class="col-md-4 text-right"><span class="label label-success " >难:{{ against }}</span></div>
                </div>
                <div class="time">
                  {{ a.submit_time }}&#x3000;{{ a.sub_user.username }}
                </div>
                {% if answer %}
                {% for a in answer %}
                    <div class="media">
                  <a class="media-left" href="#">
                    <img class="media-object" src="">
                  </a>
                  <div class="media-body">
                    <h4 class="media-heading">回复者:{{ a.ans_user.username }}</h4>
                      {% autoescape off %}
                          {{ a.content }}
                      {% endautoescape %}
                    <div class="row keys">
                      <div class="col-md-8"><span class="label label-success">{{ a.ans_question.type.types }}</span>
                        <span class="label label-success">{{ a.ans_question.tag.tags}}</span></div>
                      <div class="col-md-4 text-right">
                          <span class="label label-danger zan" name="{{ a.id }}" id="f{{ a.id }}"  style="cursor: pointer">赞</span></div>
                    </div>
                    <div class="time">
                      {{ a.ans_time }}
                    </div>
                  </div>
                </div>
                {% endfor %}
                {% endif %}
              </div>
            </div>

            <br>
            <br>
            <form action="/question/answer/?id={{ ans_id }}" method="POST" class="answer-form" >
                {% csrf_token %}
              <div class="form-group">
                <!-- <textarea class="form-control" rows="6" placeholder="请填写回答内容"></textarea> -->
                <textarea class="form-control" name="answer" rows="6" id="post" required></textarea>
              </div>
              <button type="submit" class="btn btn-success">
                <span class="glyphicon glyphicon-ok"></span> 确定提交
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="text-center page-footer">
    <p class="visible-xs-block visible-sm-block visible-md-inline visible-lg-inline">智游教育问答 &nbsp;&nbsp; &copy;zhiyou100.com</p>
    <p class="visible-md-inline visible-lg-inline">&nbsp;&nbsp;</p>
    <p class="visible-md-inline visible-lg-inline">河南智游臻龙教育科技有限公司</p>
  </div>
  <script src="{% static 'libs/jquery/jquery.js' %}"></script>
  <script src="{% static 'libs/bootstrap/js/bootstrap.js' %}"></script>
  <script src="{% static 'libs/simditor/scripts/module.min.js' %}"></script>
  <script src="{% static 'libs/simditor/scripts/hotkeys.min.js' %}"></script>
  <script src="{% static 'libs/simditor/scripts/simditor.min.js' %}"></script>
  <script>
  $(function() {
    // 上传文件按钮触发
    // $('#cover').find('button').click(function() {
    //   $('#cover').find('input[type=file]').click();
    // });

    // 创建编辑器
    new Simditor({
      // 必选项，选定元素
      textarea: $('#post'),
      // 设定工具栏功能
      toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color',
        '|', 'ol', 'ul', 'blockquote', 'code', 'table',
        '|', 'link', 'image', 'hr',
        '|', 'indent', 'outdent', 'alignment'
      ]
    })
  });
      $('.zan').each(function () {
          $(this).click(function () {
              id=$(this).attr('name');
              $.post(
                  '/question/toupiao/',
                  {'id':id,'stat':2},
                  function (data) {
                      $('#f'+id).html('赞:'+data.num)
                  }
              )
          })
      })
  </script>
</body>

</html>
